package easy;

public class Solution_914 {
    public boolean hasGroupsSizeX(int[] deck) {
        int[] array = new int[10000];
        for (int i = 0; i < deck.length; i++) {
            array[deck[i]]++;
        }
        int min = deck.length;
        for (int i = 0; i < array.length; i++) {
            if (array[i] > 0) {
                min = Math.min(min, array[i]);
            }
        }
        if (min < 2) {
            return false;
        }
        for (int i = 2; i <= min; i++) {
            boolean flag = true;
            for (int j = 0; j < array.length; j++) {
                if (array[j] > 0 && array[j] % i != 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Solution_914 model = new Solution_914();
        System.out.println(model.hasGroupsSizeX(new int[]{1}));
        System.out.println(model.hasGroupsSizeX(new int[]{1, 2, 3, 4, 4, 3, 2, 1}));
        System.out.println(model.hasGroupsSizeX(new int[]{1, 1, 1, 2, 2, 2, 3, 3}));
        System.out.println(model.hasGroupsSizeX(new int[]{1, 1}));
        System.out.println(model.hasGroupsSizeX(new int[]{1, 1, 2, 2, 2, 2}));
        System.out.println(model.hasGroupsSizeX(new int[]{1, 1, 1, 1, 2, 2, 2, 2, 2, 2}));
    }
}
